class Solution {
public:
    bool evaluateTree(TreeNode* root) {
        if (root->left == nullptr)return root->val;
        int ans1 = evaluateTree(root->left);
        int ans2 = evaluateTree(root->right);
        int ans = ans1 | ans2;
        if (root->val == 3)ans = ans1 & ans2;
        return ans;
    }
};